﻿using BlueportCoffee.model;
using System;

namespace BlueportCoffee.RobotModel
{
    public class RobotOperate
    {
        public static string RobotOperateUrl = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
        public static int handle1 = 0;
        public static int handle2 = 0;
        public static double PI = 3.1415926535;
        private static RobotOperate instance;
        private RobotOperate() { }
        public static RobotOperate Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new RobotOperate();
                }
                return instance;
            }
        }
 
        /// <summary>
        /// 左臂状态查询
        /// </summary>
        public void Robot_L_Show()
        {
            bool RobotYX = RobotModelLeft.Instance.LRobotJQRYX_Sel();//运行
            bool RobotBJ = RobotModelLeft.Instance.LRobotJQRBJ_Sel();//报警
          //  bool RobotKJ = RobotModelLeft.Instance.LRobotJQRYKJ_Sel();//开机
            bool RobotSD = RobotModelLeft.Instance.LRobotJQRYSD_Sel();//上电
            bool RobotSN = RobotModelLeft.Instance.LRobotJQRYSN_Sel();//使能
            //bool RobotZT = RobotModelLeft.Instance.LRobotJQRZT_Sel();//暂停
            bool RobotYD = RobotModelLeft.Instance.LRobotDYD_Sel();//运动
            if (RobotSD)
                RobotMsgs(false, true, false, false, false, false, false);
            if (RobotSN)
                RobotMsgs(false, false, true, false, false, false, false);
            if (RobotYX)
                RobotMsgs(false, false, false, true, false, false, false);
            //if (RobotZT)
            //    RobotMsgs(false, false, false, false, false, true, false);
            if (!RobotSN)
                RobotMsgs(false, true, false, false, false, false, false);
            if (!RobotSD)
                RobotMsgs(true, false, false, false, false, false, false);
            if (RobotBJ)
                RobotMsgs(false, false, false, false, false, false, true);
        }
        /// <summary>
        /// 机器人状态
        /// </summary>
        /// <param name="KJ">开机</param>
        /// <param name="SD">上电</param>
        /// <param name="SN">使能</param>
        /// <param name="YX">运行</param>
        /// <param name="TZ">停止</param>
        /// <param name="ZT">暂停</param>
        /// <param name="BJ">报警</param>
        ///  <param name="type">左右手 0 左 1 右</param>
        public void RobotMsgs(bool KJ, bool SD, bool SN, bool YX, bool TZ, bool ZT, bool BJ, int type = 0)
        {
            if (type == 0)
            {
                RobotMsg.Instance.Robot_YKJ_L = KJ;
                RobotMsg.Instance.Robot_SD_L = SD;
                RobotMsg.Instance.Robot_SN_L = SN;
                RobotMsg.Instance.Robot_YX_L = YX;
                RobotMsg.Instance.Robot_TZ_L = TZ;
                RobotMsg.Instance.Robot_ZT_L = ZT;
                RobotMsg.Instance.Robot_BJ_L = BJ;
            }
            else
            {
                RobotMsg.Instance.Robot_YKJ_R = KJ;
                RobotMsg.Instance.Robot_SD_R = SD;
                RobotMsg.Instance.Robot_SN_R = SN;
                RobotMsg.Instance.Robot_YX_R = YX;
                RobotMsg.Instance.Robot_TZ_R = TZ;
                RobotMsg.Instance.Robot_ZT_R = ZT;
                RobotMsg.Instance.Robot_BJ_R = BJ;
            }
        }
    }
}
